package cn.iocoder.yudao.module.product.enums.spu;

import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * 充值类型
 *
 * @author lizhongwen
 */
@Getter
@AllArgsConstructor
public enum RechargeTypeEnum implements IntArrayValuable {

    GIFT_CARD(0, "GIFT CARD"),
    DIRECT_TOPUP(1, "DIRECT TOPUP");

    /**
     * 值
     */
    private final int value;

    /**
     * 描述
     */
    private final String desc;

    public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(RechargeTypeEnum::getValue).toArray();

    @Override
    public int[] array() {
        return ARRAYS;
    }

    public RechargeTypeEnum fromValue(int value) {
        for (RechargeTypeEnum item : values()) {
            if (item.value == value) {
                return item;
            }
        }
        throw new IllegalArgumentException("枚举类型 RechargeTypeEnum 不支持整型值：" + value);
    }
}
